package com.xiaoshuidi.cloud.module.rooms.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 合同状态的枚举类 待审批 |  待签约 |已生效 | 正常结束 | 非正常结束 |
 * private String contractStatus;
 *
 * @author 合房源码
 */
@Getter
@AllArgsConstructor
public enum RoomContractStatusEnum {

    PENDING("pending", "待审批"),
    NO_SIGNED("no_signed", "待签约"),
    ACTIVE("active", "已生效"),
    CHECK_IN("check_in", "入住"),
    NORMAL_END("normal_end", "正常结束"),
    ABNORMAL_END("abnormal_end", "非正常结束"),
    REJECT("reject", "审批驳回"),
    NULLIFY("nullify", "合同作废"),
    LOST_EFFECTIVENESS("lost_effectiveness","已失效"),
    TO_BE_CHECK_IN_LOST_EFFECTIVENESS("to_be_check_in_lost_effectiveness","待入住失效"),
    OVERDUE("overdue","逾期"),
    ;
    //编码
    private final String code;
    //信息
    private final String msg;

    private static Map<String, RoomContractStatusEnum> enumMap = new HashMap<>();
    static {
        RoomContractStatusEnum[] values = RoomContractStatusEnum.values();
        for (RoomContractStatusEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }
    public static RoomContractStatusEnum getEnum(String num){
        return enumMap.get(num);
    }

    public static RoomContractStatusEnum getContractStatusEnumByCode(String code) {
        RoomContractStatusEnum[] roomContractStatusEnums = values();
        for (RoomContractStatusEnum roomContractStatusEnum : roomContractStatusEnums) {
            if (roomContractStatusEnum.code.equals(code)) {
                return roomContractStatusEnum;
            }
        }
        return null;
    }
}
